
// 主页地市账号情况显示
function index_get_team(){
    $.getJSON("/api/getteam",function(json){
        $('#index-teams').html('');
        // var html='';
        // console.log(json);
        var count_city = 0;
        var count_user = 0;
        $.each(json.city_names, function(index,value){
            $('#index-teams').append('<ul city_name="'+value.city_name+'"></ul>');
            $('#index-teams ul[city_name="'+value.city_name+'"]').append('<br><h4>'+value.city_name+'<input type="checkbox"></h4>');
            count_city ++;
        });
        $.each(json.data, function(index,value){
            $('#index-teams ul[city_name="'+value.city_name+'"]').append('<li><input type="checkbox" id="'+value.key+'"><label title="'+value.team_name+'" for="'+value.key+'">'+value.city_name+'_'+value.used_team+'_'+value.real_name+'</label></li>');
            count_user ++;
            // html+='<li><input type="checkbox" id="'+value.key+'"><label title="'+value.team_name+'" for="'+value.key+'">'+value.city_name+'#'+value.used_team+'</label></li>';
        });
        $('.page[tab="index"] h5').html("共"+count_city+"个地市,"+count_user+"个账号。");
    });
};

// 点击地市复选框切换全选
$(document).on("click","#index-teams h4 input",function(){
    let check_state = this.checked;
    $(this).parent().parent().children('li').each(function(index,value){
        $(this).children('input').prop("checked",check_state);
    });
});

// 取得选中的city_id，返回字典
function index_getChoiceValues(){
    var sub_data = [];
    $.each($('#index-teams li input'),function(index,value){
        if (value.checked) {
            sub_data.push(value.id);
        }
    });
    return sub_data;
}